/*****************************************************
Copyright (C) 2020. All rights reserved.
File name     ：ShellSort.c
Version       ：v1.0
Author        ：zhengqijun
Date          ：2020-04-06
Function List ：
Description   ：Shell Sort
******************************************************/

#include "ShellSort.h"

void ShellSort(ElementType A[], int N) {
    int i;
    int j;
    int Increment;
    ElementType Tmp;

    for (Increment = N / 2; Increment > 0; Increment /= 2) {
        for (i = Increment; i < N; ++i) {
            Tmp = A[i];
            for (j = i; j >= Increment; j -= Increment) {
                if (Tmp < A[j - Increment]) {
                    A[j] = A[j - Increment];
                } else {
                    break;
                }
            }

            A[j] = Tmp;
        }
    }
}

// EOF

